<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增自然灾害视频')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <style>
        .file-input .file-preview{
            display: none!important;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-zrVideo-add">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">分类：</label>
                    <div class="col-sm-8">
                        <select id="typeId" name="typeId" class="form-control m-b">
                            <option th:each="dict : ${typeList}" th:text="${dict.typeName}" th:value="${dict.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">自然灾害视频地址：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="videoUrl">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="videoUrl" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注：</label>
                    <div class="col-sm-8">
                        <textarea name="remark" class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "ziran/zrVideo"
        $("#form-zrVideo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {

            if ($.validate.form()) {
                var data = $("#form-user-add").serializeArray();
                var typeId = $("input[id='typeId']").is(':checked') == true ? 0 : 1;
                data.push({"name": "typeId", "value": typeId});
                $.operate.save(prefix + "/add", $('#form-zrVideo-add').serialize());
            }
        }

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>